<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    var str =  'abcabcdeed'
    var substr='',maxLength=0
    var lengthOfLongestSubstring = function(s) {
        for (let i = 0; i < s.length; i++) {
            var findIndex = substr.indexOf(s[i])
            if (findIndex!=-1){
                substr=substr.substring(findIndex+1)
            }
            substr += s[i]
            console.log(substr)
            if (substr.length>maxLength){
                maxLength = substr.length
            }
        }
        return maxLength
    }
    console.log(lengthOfLongestSubstring(str));
</script>
</body>
</html>
